<?php
/**
 *
 * Enter address data for the cart, when anonymous users checkout
 *
 * @package    VirtueMart
 * @subpackage User
 * @author Oscar van Eijk, Max Milbers
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: edit_address.php 6406 2012-09-08 09:46:55Z Milbo $
 */
// Check to ensure this file is included in Joomla!
defined ('_JEXEC') or die('Restricted access');
// vmdebug('user edit address',$this->userFields['fields']);
// Implement Joomla's form validation
JHTML::_ ('behavior.formvalidation');
//JHTML::stylesheet ('vmpanels.css', JURI::root () . 'components/com_virtuemart/assets/css/');
//JHtml::stylesheet(Juri::base().'templates/cashdressing/bootstrap/css/bootstrap.css');

JHtml::script($this->baseurl."/components/com_virtuemart/assets/js/cash/homejs.js");



/*if ($this->fTask === 'savecartuser') {
	$rtask = 'registercartuser';
	$url = 0;
}
else {
	$rtask = 'registercheckoutuser';//index.php?option=com_cashbag&view=cashbag&task=imprimer_etiq
	//$url = JRoute::_ ('index.php?option=com_virtuemart&view=cart&task=checkout', $this->useXHTML, $this->useSSL);
}*/
$url = JRoute::_ ('index.php?option=com_cashbag&view=cashbag&task=imprimer_etiq', $this->useXHTML, $this->useSSL);
?>
<!--h1><?php// echo $this->page_title ?></h1-->
<?php
//echo shopFunctionsF::getLoginForm (TRUE, FALSE, $url);
?>
<script language="javascript">
    
	function myValidator(f, t) {
		f.task.value = t; //this is a method to set the task of the form on the fTask.
		if (document.formvalidator.isValid(f)) {
                        f.submit();
			return true;
		} else {
			var msg = '<?php echo addslashes (JText::_ ('COM_VIRTUEMART_USER_FORM_MISSING_REQUIRED_JS')); ?>';
			alert(msg + ' ');
		}
		return false;
	}
        
       
	function callValidatorForRegister(f) {

		var elem = jQuery('#username_field');
		elem.attr('class', "required");

		var elem = jQuery('#name_field');
		elem.attr('class', "required");

		var elem = jQuery('#password_field');
		elem.attr('class', "required");

		var elem = jQuery('#password2_field');
		elem.attr('class', "required");

		var elem = jQuery('#userForm');

		return myValidator(f, '<?php echo $rtask ?>');

	}
        function step2(f, url){//passer de l'étape 1 à la 2 lors de la demande de sac!
            
            if (document.formvalidator.isValid(f)) {
       
                    window.location.href=url;
                    return true;
		} else {
			
			alert('Votre adresse n\'est pas valide');
                        return false;
		}
        }
        
 function step22(url){//valide la demand de sac
     
     var bValid= true;
     
     if(jQuery("input[name=croix_rouge]:checked").val()!=='oui' && jQuery("input[name=croix_rouge]:checked").val()!=='non')
         bValid= false;
     
     if(jQuery("input[name=conditions_ventes]:checked").val()!=='lue' )
        bValid= false;
     if(jQuery("input[name=conditions_envoie]:checked").val()!=='vet')
        bValid= false;
     if(jQuery("input[name=conditions_marques]:checked").val()!=='marq')
         bValid= false;
     if(bValid===true){
         window.location.href=url;
     }else{
         alert("Vous devez cocher toutes les cases");
     }
     
 }
</script>

<div class="wrap">
    <span class="commade_sac">
        
        <div class="bande_chevron_1">
            <span class="display_parts part_1">CONFIRMER MON ADRESSE</span>
            <span class="display_parts part_2">CGV</span>
            <span class="display_parts part_3">VALIDER</span>
        </div>
        
    </span>

	<form method="post" id="userForm" name="userForm" class="form-validate">
		
            <div class="form_modifier_adr">
                <span class="input_part">
			<?php
			
                        $rview = 'user';

                        $this->address_type = 'ST';
			
			?>
                            
               <?php

		if (count ($this->userFields['functions']) > 0) {
			echo '<script language="javascript">' . "\n";
			echo join ("\n", $this->userFields['functions']);
			echo '</script>' . "\n";
		}
		echo $this->loadTemplate ('userfields');

		?>

        <input type="hidden" name="option" value="com_virtuemart"/>
        <input type="hidden" name="view" value="user"/>
        <input type="hidden" name="controller" value="user"/>
        <input type="hidden" name="task" value="<?php echo $this->fTask; // I remember, we removed that, but why?   ?>"/>
        <input type="hidden" name="layout" value="<?php echo $this->getLayout (); ?>"/>
        <input type="hidden" name="address_type" value="<?php echo $this->address_type; ?>"/>
        <?php if (!empty($this->virtuemart_userinfo_id)) {
                echo '<input type="hidden" name="shipto_virtuemart_userinfo_id" value="' . (int)$this->virtuemart_userinfo_id . '" />';
        }
        echo JHTML::_ ('form.token');
        ?>
        </span>
        <span class="button_part">
				<button class="btn_cash_green_mini" type="submit"
				        onclick="javascript:return myValidator(userForm, '<?php echo $this->fTask; ?>');">Valider les modifications<?php //echo JText::_ ('COM_VIRTUEMART_SAVE'); ?></button>
				<!--button class="btn_cash_black_mini" type="reset"
				        onclick="window.location.href='<?php //echo JRoute::_ ('index.php?option=com_virtuemart&view=' . $rview); ?>'"><?php echo JText::_ ('COM_VIRTUEMART_CANCEL'); ?></button-->
        </span>
     </div>
</form>
    <span class="span_end_page">
        <button class="btn_cash_green" id="go_stape_2" onclick="step2(userForm,'<?php echo JRoute::_ ('index.php?option=com_cashbag&view=cashbag&task=requestbag&layout=confirmation&type='.JFactory::getApplication()->input->get('type')); ?>');">
            Passer &agrave; l'&eacute;tape suivante >>
        </button>
    </span>
</div>